package org.huaxi.core;


import org.huaxi.support.NamedThreadLocal;

/**
 * Created by huwei on 2019/5/10.
 */
public class DataSourceNameHolder {

  private static final ThreadLocal<String> dataSourceNameHolder =
          new NamedThreadLocal<>("DataSource");


  public static String get() {
    return dataSourceNameHolder.get();
  }

  public static void set(String dataSourceName) {
    if (dataSourceName == null) {
      reset();
    } else {
      dataSourceNameHolder.set(dataSourceName);
    }
  }

  public static void reset() {
    dataSourceNameHolder.remove();
  }

}
